<div id="language-select">

<?php 

    if(sizeof($languages) < 4) {

        // Render options as links

        $lastElement = end($languages);

        foreach($languages as $key=>$lang) {

            if($key != $currentLang) {

                echo '<li class="lang_item">'.CHtml::link(

                     $lang, 

                     $this->getOwner()->createMultilanguageReturnUrl($key),
                     array('class'=>'lang_link')).'</li>';

            } else echo '<li class="lang_item"><sel class="lang_link">'.$lang.'</sel></li>';

            //if($lang != $lastElement) echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';

        }

    }

    else {

        // Render options as dropDownList

        echo CHtml::form();

        foreach($languages as $key=>$lang) {

            echo CHtml::hiddenField(

                $key, 

                $this->getOwner()->createMultilanguageReturnUrl($key));

        }

        echo CHtml::dropDownList('language', $currentLang, $languages,

            array(

                //'submit'=>'',

                'onchange'=>'this.form.submit()',

            )

        ); 

        echo CHtml::endForm();

    }

?>

</div>